Tag Archives: npm run build

[Solved] Possible reasons why NPM run build cannot package NPM err! missing script: build

Error: npm ERR! missing script: build,It was later discovered that the scripts parameter in package.json is:
“scripts”: {undefined
“dev”: “vue-cli-service serve”,
“build:prod”: “vue-cli-service build”,
“build:stage”: “vue-cli-service build –mode staging”,
“preview”: “node build/index.js –preview”,
“lint”: “eslint –ext .js,.vue src”,
“test:unit”: “jest –clearCache && vue-cli-service test:unit”,
“test:ci”: “npm run lint && npm run test:unit”,
“svgo”: “svgo -f src/icons/svg –config=src/icons/svgo.yml”
},So the right commands is:
npm run build:prod --report

Solve the compilation errors encountered when NPM run build is executed by the library schematics downloaded from the official website of angular

The library schematics example I downloaded on the official website of angular encountered the following error when running the command line NPM run build:

npm run build

my- [email protected] build c:\Code\SPA\schematics-for-libraries\projects\my-lib

tsc -p tsconfig.schematics.json

schematics/my-service/index.ts:39:7 – error TS2322: Type ‘string | number | boolean | JsonArray | JsonObject | null | undefined’ is not assignable to type ‘string | undefined’.

Type ‘null’ is not assignable to type ‘string | undefined’.

39 options.project = workspace.extensions.defaultProject;

~~~~~~~~~~~~~~~

schematics/my-service/index.ts:42:44 – error TS2345: Argument of type ‘string | undefined’ is not assignable to parameter of type ‘string’.

Type ‘undefined’ is not assignable to type ‘string’.

resolvent

The data type of this project is defined in schema.ts, so it can be adjusted to be consistent with workspace.extensions.defaultproject.

Before modification:

After modification, a new problem is encountered: cannot find name ‘jsonarray’

In fact, you can add as string directly to the original code position, which means to tell the compiler that the programmer knows very well that in this context, the type of workspace.extensions.defaultproject, must be

Another error was encountered after repair:

‘options’ is declared but its value is never read.ts(6133)

The solution to this error is relatively simple:

The parameter name can be preceded by an underscore.

Finally, NPM run build is successfully executed:

More Jerry’s original articles can be found in: “Wang Zixi”:

NPM run build Error: [BABEL] No “exports” main defined in

According to guesses, it should be a project created under a low version of nodejs. In a high version of nodejs, compilation problems caused by version differences

Solution

Modify the configuration of exports in node_modules\@babel\helper-compilation-targets\package.json as follows:

{
   ...,
   "exports": {
    ".":"./lib/index.js"
   }
}

NPM run build Error: operation not permitted

1. The project uses Vue framework in NPM run build  Package error:

Access the corresponding directory and find that it cannot be opened. It turns out that the file is occupied by other applications. After a careful look, the xftp file transfer software is open. After closing it, run NPM run build again

the reason for this problem is that when building a project, the previously built project file will be deleted. Because the file is occupied, the file cannot be deleted, so an error will be reported. Just close the corresponding occupation program

2. Vue will report an error after packaging, but the local NPM run dev will not report an error. After checking the reason, it is found that several Chinese names of the packaged JS files are garbled. Change them to English and then package them

 

npm run build : No such file or directory [How to Solve]

Phenomenon

React project, npm run build uses babel with browserify, as follows.

babel --presets es2015,react js/source -d js/build
browserify js/build/index.js -o bundle.js

Run error:

/bin/sh: /c/Users/xxx/AppData/Local/Yarn/bin/../Data/global/node_modules/.bin/babel: No such file or directory
/bin/sh: /c/Users/xxx/AppData/Local/Yarn/bin/../Data/global/node_modules/.bin/browserify: No such file or directory

Settle

Access C:/users/xxx/appdata/local/Yan/data/global/node in the folder directory_Modules /. Bin/, there is only one serve in this folder:

the required Babel and Browse (the specific reason has not been found)
since it is missing, Re yarn add :

yarn global add babel
yarn global add browserify

However, in the process of packaging yarn global add Babel , the following errors are reported:

error An unexpected error occurred: "EPERM: operation not permitted, unlink 'C:\\Users\\xxx\\AppData\\Local\\Yarn\\Data\\global\\node_modules\\.bin\\serve'".

Solution please go to another essay on this site: Yan add package error: operation not allowed, unlink